﻿using CodeTop.CodeTop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Solution415
{
    public string AddStrings(string num1, string num2)
    {

        int len1=num1.Length;
        int len2=num2.Length;
        
        Stack<int> list=new Stack<int>();  

        if(len2>len1)
        {
            return AddStrings(num2, num1);
        }

        int next = 0;
        //遍历短的
        for (int i=1; i<=len2; i++)
        {
            Console.WriteLine(int.Parse(num1[len1 - i].ToString()));
            int sum = next+ int.Parse(num1[len1-i].ToString()) + int.Parse(num2[len2 - i].ToString());

            int cur = sum % 10;
            next = sum / 10;
            list.Push(cur);
            Console.WriteLine(cur);

        }

        int restLen=len1-len2;
        for (int i = 1; i <= restLen; i++)
        {
            int sum = next + int.Parse(num1[restLen-i].ToString());

            int cur = sum % 10;
            next = sum / 10;
            list.Push(cur);
        }
        if (next > 0)
        {
            list.Push(next);
        }
        string res = "";
while (list.Count > 0)
        {


         
            res += list.Pop();
        }
return res;
    }
}

class Program415
{
    static void Main415(string[] args)
    {

        string a = "11";
        string b = "123";
        Solution415 solution = new Solution415();
        string res = solution.AddStrings(a, b);
        Console.WriteLine(res);

    }
}